﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace UTLBASEFORM
{
    public partial class MDIPARENT1 : DevComponents.DotNetBar.Office2007RibbonForm
    {

        #region Private Constant
        protected const string ImageNameProduct="Product";
        protected const string ImageNameTem = "Tem";
        protected const string ImageNameProductSell = "ProductSell";
        protected const string ImageNameReport = "Report";
        protected const string ImageNameReportIn = "ReportIn";
        protected const string ImageNameReportOut = "ReportOut";
        protected const string ImageNameReportDay = "ReportDay";
        protected const string ImageNameReportInStock = "ReportInStock";
        protected const string ImageNameReportCustomer = "ReportCustomer";
        protected const string ImageNameSearch = "Search";
        protected const string ImageNameSearchBarCode = "SearchBarCode";
        protected const string ImageNameCustomer = "Customer";
        protected const string ImageNameMember = "Member";
        protected const string ImageNameSystem = "System";
        protected const string ImageNameCheckStock = "CheckStock";
        #endregion

        #region Private field define
        //the selected(focused) picturePox->Form
        private int intFocusedPicID = -1;
        //the panel size
        private Size sizeAdvCtrlTabPanel = new Size(330, 240);
        //picture box size
        private Size sizeAdvCtrlTabPic = new Size(95, 72);
        //picture box count in one row
        private int intPreviewPicCountInRow = 3;
        //the Preview panel
        private Panel pnlAdvancedCtrlTab = new Panel();
        //the label that contains the caption of the selected form
        private Label lblSelectedChildCaption = new Label();

        protected CRate _Crate;
        
        #endregion
        #region "Rate Property"
        public CRate CRATE
        {
            get { return _Crate; }
            set { _Crate = value; }
        }
        #endregion
        #region Protected field define
        protected string _UserName;
        protected int _ID;
        protected int _AuthenticationID;
        protected string _FullName;

        protected CUserLoginInfo userLoginInfo;


        #endregion
        public MDIPARENT1()
        {
            InitializeComponent();
            foreach (Control act in this.Controls)
            {
                if (act is MdiClient)
                {
                    //use the MouseWheel event to show the panel with previews and scroll between the forms
                    act.MouseWheel += new MouseEventHandler(MdiClient_MouseWheel);
                    break;
                }
            }
            //Khoi dong tinh nang scroll
            bool _enable = false;
            try
            {
                _enable = bool.Parse(ConfigurationManager.AppSettings["ScrollMDIChild"].ToString());
            }
            catch
            {
                _enable = false;
            }
            InitializeCtrlTab(_enable);
            tab1.Click += new EventHandler(tab1_Click);
            tab2.Click += new EventHandler(tab2_Click);
            tab3.Click += new EventHandler(tab3_Click);
            tab4.Click += new EventHandler(tab4_Click);
            tab5.Click += new EventHandler(tab5_Click);
            tab6.Click += new EventHandler(tab6_Click);
            tab7.Click += new EventHandler(tab7_Click);
            tab8.Click += new EventHandler(tab8_Click);
            tab9.Click += new EventHandler(tab9_Click);
            tab10.Click += new EventHandler(tab10_Click);
            tab11.Click += new EventHandler(tab11_Click);
            tab12.Click += new EventHandler(tab12_Click);
            btnAbout.Click += new EventHandler(btnAbout_Click);
            btnOption.Click += new EventHandler(btnOption_Click);
            btnExist1.Click += new EventHandler(btnExist1_Click);
        }

        #region Si kien cho cac nut mennu

        protected virtual void btnExist1_Click(object sender, EventArgs e)
        {
            
        }

        protected virtual void btnOption_Click(object sender, EventArgs e)
        {
            
        }

        protected virtual void btnAbout_Click(object sender, EventArgs e)
        {
            
        }
        #endregion

        public CUserLoginInfo UserLoginInfo
        {
            get { return userLoginInfo; }
            set { userLoginInfo = value; }
        }
        #region Tab Define

        #region TAB1 Define
        /// <summary>
        /// BTN 1 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB1(string textlabel, string imgname)
        {
            this.tab1.Visible = true;
            this.tab1.Text = textlabel;
            //this.tab1.Image = MDICHILD.getImage(imgname);
            this.tab1.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 1 Hide.
        /// </summary>
        public void HideTAB1()
        {
            this.tab1.Visible = false;
        }
        /// <summary>
        /// BTN 1 Enable.
        /// </summary>
        public void EnableTAB1()
        {
            this.tab1.Enabled = true;
        }
        /// <summary>
        /// BTN 1 Disable.
        /// </summary>
        public void DisableTAB1()
        {
            this.tab1.Enabled = false;
        }
        /// <summary>
        /// TAB1 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab1_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("F1");
        }
        #endregion
        #region TAB2 Define
        /// <summary>
        /// BTN 2 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB2(string textlabel, string imgname)
        {
            this.tab2.Visible = true;
            this.tab2.Text = textlabel;
            //this.tab2.Image = MDICHILD.getImage(imgname);
            this.tab2.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 2 Hide.
        /// </summary>
        public void HideTAB2()
        {
            this.tab2.Visible = false;
        }
        /// <summary>
        /// BTN 2 Enable.
        /// </summary>
        public void EnableTAB2()
        {
            this.tab2.Enabled = true;
        }
        /// <summary>
        /// BTN 2 Disable.
        /// </summary>
        public void DisableTAB2()
        {
            this.tab2.Enabled = false;
        }
        /// <summary>
        /// TAB2 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab2_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB3 Define
        /// <summary>
        /// BTN 3 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB3(string textlabel, string imgname)
        {
            this.tab3.Visible = true;
            this.tab3.Text = textlabel;
            //this.tab3.Image = MDICHILD.getImage(imgname);
            this.tab3.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 3 Hide.
        /// </summary>
        public void HideTAB3()
        {
            this.tab3.Visible = false;
        }
        /// <summary>
        /// BTN 3 Enable.
        /// </summary>
        public void EnableTAB3()
        {
            this.tab3.Enabled = true;
        }
        /// <summary>
        /// BTN 3 Disable.
        /// </summary>
        public void DisableTAB3()
        {
            this.tab3.Enabled = false;
        }
        /// <summary>
        /// TAB3 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab3_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB4 Define
        /// <summary>
        /// BTN 4 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB4(string textlabel, string imgname)
        {
            this.tab4.Visible = true;
            this.tab4.Text = textlabel;
            //this.tab4.Image = MDICHILD.getImage(imgname);
            this.tab4.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 4 Hide.
        /// </summary>
        public void HideTAB4()
        {
            this.tab4.Visible = false;
        }
        /// <summary>
        /// BTN 4 Enable.
        /// </summary>
        public void EnableTAB4()
        {
            this.tab4.Enabled = true;
        }
        /// <summary>
        /// BTN 4 Disable.
        /// </summary>
        public void DisableTAB4()
        {
            this.tab4.Enabled = false;
        }
        /// <summary>
        /// TAB4 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab4_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB5 Define
        /// <summary>
        /// BTN 5 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB5(string textlabel, string imgname)
        {
            this.tab5.Visible = true;
            this.tab5.Text = textlabel;
            //this.tab5.Image = MDICHILD.getImage(imgname);
            this.tab5.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 5 Hide.
        /// </summary>
        public void HideTAB5()
        {
            this.tab5.Visible = false;
        }
        /// <summary>
        /// BTN 5 Enable.
        /// </summary>
        public void EnableTAB5()
        {
            this.tab5.Enabled = true;
        }
        /// <summary>
        /// BTN 5 Disable.
        /// </summary>
        public void DisableTAB5()
        {
            this.tab5.Enabled = false;
        }
        /// <summary>
        /// TAB5 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab5_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB6 Define
        /// <summary>
        /// BTN 6 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB6(string textlabel, string imgname)
        {
            this.tab6.Visible = true;
            this.tab6.Text = textlabel;
            //this.tab6.Image = MDICHILD.getImage(imgname);
            this.tab6.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 6 Hide.
        /// </summary>
        public void HideTAB6()
        {
            this.tab6.Visible = false;
        }
        /// <summary>
        /// BTN 6 Enable.
        /// </summary>
        public void EnableTAB6()
        {
            this.tab6.Enabled = true;
        }
        /// <summary>
        /// BTN 6 Disable.
        /// </summary>
        public void DisableTAB6()
        {
            this.tab6.Enabled = false;
        }
        /// <summary>
        /// TAB6 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab6_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB7 Define
        /// <summary>
        /// BTN 7 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB7(string textlabel, string imgname)
        {
            this.tab7.Visible = true;
            this.tab7.Text = textlabel;
            //this.tab7.Image = MDICHILD.getImage(imgname);
            this.tab7.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 7 Hide.
        /// </summary>
        public void HideTAB7()
        {
            this.tab7.Visible = false;
        }
        /// <summary>
        /// BTN 7 Enable.
        /// </summary>
        public void EnableTAB7()
        {
            this.tab7.Enabled = true;
        }
        /// <summary>
        /// BTN 7 Disable.
        /// </summary>
        public void DisableTAB7()
        {
            this.tab7.Enabled = false;
        }
        /// <summary>
        /// TAB7 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab7_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB8 Define
        /// <summary>
        /// BTN 8 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB8(string textlabel, string imgname)
        {
            this.tab8.Visible = true;
            this.tab8.Text = textlabel;
            //this.tab8.Image = MDICHILD.getImage(imgname);
            this.tab8.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 8 Hide.
        /// </summary>
        public void HideTAB8()
        {
            this.tab8.Visible = false;
        }
        /// <summary>
        /// BTN 8 Enable.
        /// </summary>
        public void EnableTAB8()
        {
            this.tab8.Enabled = true;
        }
        /// <summary>
        /// BTN 8 Disable.
        /// </summary>
        public void DisableTAB8()
        {
            this.tab8.Enabled = false;
        }
        /// <summary>
        /// TAB8 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab8_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB9 Define
        /// <summary>
        /// BTN 9 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB9(string textlabel, string imgname)
        {
            this.tab9.Visible = true;
            this.tab9.Text = textlabel;
            //this.tab9.Image = MDICHILD.getImage(imgname);
            this.tab9.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 9 Hide.
        /// </summary>
        public void HideTAB9()
        {
            this.tab9.Visible = false;
        }
        /// <summary>
        /// BTN 9 Enable.
        /// </summary>
        public void EnableTAB9()
        {
            this.tab9.Enabled = true;
        }
        /// <summary>
        /// BTN 9 Disable.
        /// </summary>
        public void DisableTAB9()
        {
            this.tab9.Enabled = false;
        }
        /// <summary>
        /// TAB9 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab9_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB10 Define
        /// <summary>
        /// BTN 10 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB10(string textlabel, string imgname)
        {
            this.tab10.Visible = true;
            this.tab10.Text = textlabel;
            //this.tab10.Image = MDICHILD.getImage(imgname);
            this.tab10.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 10 Hide.
        /// </summary>
        public void HideTAB10()
        {
            this.tab10.Visible = false;
        }
        /// <summary>
        /// BTN 10 Enable.
        /// </summary>
        public void EnableTAB10()
        {
            this.tab10.Enabled = true;
        }
        /// <summary>
        /// BTN 10 Disable.
        /// </summary>
        public void DisableTAB10()
        {
            this.tab10.Enabled = false;
        }
        /// <summary>
        /// TAB10 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab10_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB11 Define
        /// <summary>
        /// BTN 11 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB11(string textlabel, string imgname)
        {
            this.tab11.Visible = true;
            this.tab11.Text = textlabel;
            //this.tab11.Image = MDICHILD.getImage(imgname);
            this.tab11.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 11 Hide.
        /// </summary>
        public void HideTAB11()
        {
            this.tab11.Visible = false;
        }
        /// <summary>
        /// BTN 11 Enable.
        /// </summary>
        public void EnableTAB11()
        {
            this.tab11.Enabled = true;
        }
        /// <summary>
        /// BTN 11 Disable.
        /// </summary>
        public void DisableTAB11()
        {
            this.tab11.Enabled = false;
        }
        /// <summary>
        /// TAB11 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab11_Click(object sender, EventArgs e)
        {
        }
        #endregion
        #region TAB12 Define
        /// <summary>
        /// BTN 12 Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowTAB12(string textlabel, string imgname)
        {
            this.tab12.Visible = true;
            this.tab12.Text = textlabel;
            //this.tab12.Image = MDICHILD.getImage(imgname);
            this.tab12.Tooltip = textlabel;
        }
        /// <summary>
        /// BTN 12 Hide.
        /// </summary>
        public void HideTAB12()
        {
            this.tab12.Visible = false;
        }
        /// <summary>
        /// BTN 12 Enable.
        /// </summary>
        public void EnableTAB12()
        {
            this.tab12.Enabled = true;
        }
        /// <summary>
        /// BTN 12 Disable.
        /// </summary>
        public void DisableTAB12()
        {
            this.tab12.Enabled = false;
        }
        /// <summary>
        /// TAB12 Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        

        protected virtual void tab12_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("F12");
        }
        #endregion
        #endregion      
        #region Staus bar
        #region BTN LOG OUT Define
        /// <summary>
        /// button Logout Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param> 
        protected virtual void btnlogout_Click(object sender, EventArgs e)
        {
        }
        /// <summary>
        /// button Logout Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowBTNLOGOUT(string textlabel, string imgname)
        {
            this.btnLogout.Visible = true;
            this.btnLogout.Text = textlabel;
            this.btnLogout.Image = MDICHILD.getImage(imgname);
            this.btnLogout.ImagePosition = DevComponents.DotNetBar.eImagePosition.Top;
            this.btnLogout.Tooltip = textlabel;
        }
        /// <summary>
        /// button Logout Hide.
        /// </summary>
        public void HideBTNLOGOUT()
        {
            this.btnLogout.Visible = false;
        }
        /// <summary>
        /// button Logout Enable.
        /// </summary>
        public void EnableBTNLOGOUT()
        {
            this.btnLogout.Enabled = true;
        }
        /// <summary>
        /// button Logout Disable.
        /// </summary>
        public void DisableBTNLOGOUT()
        {
            this.btnLogout.Enabled = false;
        }
        #endregion

        #region Label User Name Define
        /// <summary>
        /// Label User Name Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param> 
        protected virtual void lblUserName_Click(object sender, EventArgs e)
        {
        }
        /// <summary>
        /// Label User Name Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowLBLUSERNAME(string textlabel, string imgname)
        {
            this.lblUserName.Visible = true;
            this.lblUserName.Text = textlabel;
            this.lblUserName.Tooltip = textlabel;
        }
        /// <summary>
        /// Label User Name Hide.
        /// </summary>
        public void HideLBLUSERNAME()
        {
            this.lblUserName.Visible = false;
        }
        /// <summary>
        /// Label User Name Enable.
        /// </summary>
        public void EnableLBLUSERNAME()
        {
            this.lblUserName.Enabled = true;
        }
        /// <summary>
        /// Label User Name Disable.
        /// </summary>
        public void DisableLBLUSERNAME()
        {
            this.lblUserName.Enabled = false;
        }
        #endregion


        #region Status Progessbar Define
        /// <summary>
        /// Status Progessbar Click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param> 
        protected virtual void pgbStatusLoading_Click(object sender, EventArgs e)
        {
        }
        /// <summary>
        /// Status Progessbar Show.
        /// </summary>
        /// <param name="textlabel">Lable to show to screen of the button</param>
        ///<param name="imgname">Image name to show</param>
        public void ShowPGBSTATUSLOADING(string textlabel, string imgname)
        {
            this.pgbStatusLoading.Visible = true;
            this.pgbStatusLoading.Text = textlabel;
            this.pgbStatusLoading.Tooltip = textlabel;
        }
        /// <summary>
        /// Status Progessbar Hide.
        /// </summary>
        public void HidePGBSTATUSLOADING()
        {
            this.pgbStatusLoading.Visible = false;
        }
        /// <summary>
        /// Status Progessbar Enable.
        /// </summary>
        public void EnablePGBSTATUSLOADING()
        {
            this.pgbStatusLoading.Enabled = true;
        }
        /// <summary>
        /// Status Progessbar Disable.
        /// </summary>
        public void DisablePGBSTATUSLOADING()
        {
            this.pgbStatusLoading.Enabled = false;
        }
        #endregion

        #endregion
        #region Login info
        public string Username
        {
            get { return _UserName; }
            set { _UserName = value; }
        }
        public string FullName
        {
            get { return _FullName; }
            set
            {
                this.lblUserName.Text = " [ " + value + " ] ";
                _FullName = value;
            }
        }

        public int ID
        {
            get { return _ID; }
            set { this._ID = value; }
        }

        public int AuthenticationID
        {
            get { return _AuthenticationID; }
            set { this._AuthenticationID = value; }
        }
        #endregion
        public DevComponents.DotNetBar.ProgressBarItem ProgressbarStatus
        {
            get { return this.pgbStatusLoading; }
            set { this.pgbStatusLoading = value; }
        }

        public void ShowMIDChild(object _mdichild)
        {
            try
            {
                _mdichild = (UTLBASEFORM.MDICHILD)_mdichild;

            }
            catch (Exception ex)
            {

                throw;
            }
        }
        /// <summary>
        /// Tao mot anh thu cho form
        /// </summary>
        /// <param name="cont"></param>
        /// <returns></returns>
        private Bitmap SaveBitmap(Control cont)
        {
            Bitmap bm = new Bitmap(cont.Width, cont.Height);
            //render into a bitmap
            cont.DrawToBitmap(bm, new Rectangle(0, 0, cont.Width, cont.Height));
            return bm;
        }

        private void InitializeCtrlTab(bool enable)
        {
            if (enable)
            {
                //set default font for the label of the selected ChildWindow
                lblSelectedChildCaption.Font = new Font(FontFamily.GenericSansSerif, 30);
                lblSelectedChildCaption.AutoSize = false;
                lblSelectedChildCaption.TextAlign = ContentAlignment.MiddleCenter;

                //set the default size of the preview panel,and a pics count in one row...
                switch (SystemInformation.PrimaryMonitorSize.Width)
                {
                    case 800:
                        sizeAdvCtrlTabPanel = new Size(330, 240);
                        intPreviewPicCountInRow = 3;
                        sizeAdvCtrlTabPic = new Size(95, 72);
                        break;
                    case 1024:
                        sizeAdvCtrlTabPanel = new Size(330, 240);
                        intPreviewPicCountInRow = 3;
                        sizeAdvCtrlTabPic = new Size(95, 72);
                        break;
                    case 1280:
                        sizeAdvCtrlTabPanel = new Size(430, 300);
                        sizeAdvCtrlTabPic = new Size(95, 72);
                        intPreviewPicCountInRow = 3;
                        break;
                    case 1440:
                        sizeAdvCtrlTabPanel = new Size(430, 300);
                        sizeAdvCtrlTabPic = new Size(95, 72);
                        intPreviewPicCountInRow = 4;
                        break;
                    case 1600:
                        sizeAdvCtrlTabPanel = new Size(430, 300);
                        sizeAdvCtrlTabPic = new Size(95, 72);
                        intPreviewPicCountInRow = 4;
                        break;
                    case 1680:
                        sizeAdvCtrlTabPanel = new Size(430, 300);
                        sizeAdvCtrlTabPic = new Size(95, 72);
                        intPreviewPicCountInRow = 4;
                        break;
                    default:
                        break;
                }
                //set the size...
                pnlAdvancedCtrlTab.Size = sizeAdvCtrlTabPanel;
                lblSelectedChildCaption.Size = new Size(sizeAdvCtrlTabPanel.Width, 50);
                //...and the background color
                lblSelectedChildCaption.BackColor = SystemColors.ControlDark;
            }
        }

        private void MDIPARENT_KeyUp(object sender, KeyEventArgs e)
        {
            if (ModifierKeys != Keys.Control)
            {
                if (intFocusedPicID == -1)
                {
                    return;
                }
                //if the user release the control key we activate the selected Form

                if (this.MdiChildren[intFocusedPicID].WindowState == FormWindowState.Minimized)
                {
                    this.MdiChildren[intFocusedPicID].WindowState = FormWindowState.Normal;
                }
                this.MdiChildren[intFocusedPicID].Activate();

                //remove the panel and the label from MDIForm controls
                this.Controls.Remove(pnlAdvancedCtrlTab);
                this.Controls.Remove(lblSelectedChildCaption);
                intFocusedPicID = -1;
            }
        }

        private void MdiClient_MouseWheel(object sender, MouseEventArgs e)
        {
            if (this.MdiChildren.Length > 0)
            {
                //if there is any ChildForm
                if (ModifierKeys == Keys.Control)
                {
                    //control key is down
                    if (!this.Contains(pnlAdvancedCtrlTab))
                    {
                        //if this is the first time, than mouse wheel scroll
                        //so we need the initialize the panel

                        //clear all PictureBox
                        pnlAdvancedCtrlTab.Controls.Clear();

                        //set the position of the pnl
                        //it set to be the center of the MDI form
                        pnlAdvancedCtrlTab.Location = new Point((int)(this.Width / 2) - (int)(pnlAdvancedCtrlTab.Width / 2), (int)(this.Height / 2) - (int)(pnlAdvancedCtrlTab.Height / 2));

                        //the position of the label
                        lblSelectedChildCaption.Location = new Point(pnlAdvancedCtrlTab.Location.X, pnlAdvancedCtrlTab.Location.Y - 50);

                        //style...
                        pnlAdvancedCtrlTab.BorderStyle = BorderStyle.Fixed3D;
                        //if the autosroll property is true and we have lot of opened childwindow, 
                        //the vertical scrollbar automatically appear
                        pnlAdvancedCtrlTab.AutoScroll = true;

                        //the x-y "index"
                        int i = 0;
                        int j = 0;
                        foreach (Form act in this.MdiChildren)
                        {
                            if (i == intPreviewPicCountInRow)
                            {
                                //if we need to change row...
                                i = 0;
                                j++;
                            }

                            //the new picture box
                            PictureBox pc = new PictureBox();
                            //set its size and location
                            pc.Location = new Point(20 + i * (sizeAdvCtrlTabPic.Width + 5), 20 + j * (sizeAdvCtrlTabPic.Height + 10));
                            pc.Size = sizeAdvCtrlTabPic;
                            //add it to the panel controls collection
                            pnlAdvancedCtrlTab.Controls.Add(pc);

                            //set the image and image size
                            pc.Image = SaveBitmap(act);
                            pc.SizeMode = PictureBoxSizeMode.Zoom;
                            i++;

                            if (act.Focused)
                            {
                                //if it is the foucused ChildWindow set its border to 3d
                                pc.BorderStyle = BorderStyle.Fixed3D;
                                intFocusedPicID = pnlAdvancedCtrlTab.Controls.Count - 1;
                                //set the label to the ChildForm caption
                                lblSelectedChildCaption.Text = act.Text;
                            }
                        }

                        if (intFocusedPicID == -1)
                        {
                            //if there isnt any focused child... we set the first selected
                            intFocusedPicID = 0;
                            (pnlAdvancedCtrlTab.Controls[0] as PictureBox).BorderStyle = BorderStyle.Fixed3D;
                        }
                        //add the panel and the textbox to to controls collection of the MDIForm
                        this.Controls.Add(pnlAdvancedCtrlTab);
                        this.Controls.Add(lblSelectedChildCaption);
                    }
                    else
                    {
                        //if it isnt the first mouse scroll

                        //set the actual picBox border to default
                        (pnlAdvancedCtrlTab.Controls[intFocusedPicID] as PictureBox).BorderStyle = BorderStyle.None;

                        //increment,or decrement the selection
                        if (e.Delta > 0)
                        {
                            intFocusedPicID++;
                            if (intFocusedPicID == pnlAdvancedCtrlTab.Controls.Count)
                            {
                                intFocusedPicID = 0;
                            }

                        }
                        else if (e.Delta < 0)
                        {
                            intFocusedPicID--;
                            if (intFocusedPicID == -1)
                            {
                                intFocusedPicID = pnlAdvancedCtrlTab.Controls.Count - 1;
                            }
                        }
                        //set the new picBox selected
                        (pnlAdvancedCtrlTab.Controls[intFocusedPicID] as PictureBox).BorderStyle = BorderStyle.Fixed3D;
                        lblSelectedChildCaption.Text = this.MdiChildren[intFocusedPicID].Text;
                    }
                }
            }

        }

        private void lblUserName_TextChanged(object sender, EventArgs e)
        {
            lblUserName.Visible = true;
            btnLogout.Visible = true;

        }

        private void btnLogout_Click_1(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn đăng xuất không?", "Tiệm Vàng Hồng Phúc", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                this.Close();
            }
        }
       
        protected void MDIChildShow(Form form)
        {
            foreach (Form frm in this.MdiChildren)
            {
                if (frm.GetType() == form.GetType())                
                {
                    frm.Focus();
                    return;
                }
            }            
            form.MdiParent = this;
            form.Show();
            form.WindowState = FormWindowState.Maximized;
            form.Refresh();
        }

        protected override void UpdateFormStyle()
        {
            base.UpdateFormStyle();
        }

        protected virtual void SetMenuWithAuthentication()
        {

        }

        protected static Image getImage(string strImage)
        {
            switch (strImage)
            {
                case ImageNameProduct:
                    return null;
                case ImageNameTem:
                    return null;
                case ImageNameProductSell:
                    return null;
                case ImageNameReport:
                    return null;
                case ImageNameReportIn:
                    return null;
                case ImageNameReportOut:
                    return null;
                case ImageNameReportDay:
                    return null;
                case ImageNameReportInStock:
                    return null;
                case ImageNameReportCustomer:
                    return null;
                case ImageNameSearch:
                    return null;
                case ImageNameSearchBarCode:
                    return null;
                case ImageNameCustomer:
                    return null;
                case ImageNameMember:
                    return null;
                case ImageNameSystem:
                    return null;
                case ImageNameCheckStock:
                    return null;
                default:
                    return null;
            }
        }

        
        

    }
}